//******************************************************************************
//                              RxDect
//
//功能：检测Rx数据及版本号
//
//v1.0		ZGragon	2021-06-17
//
//******************************************************************************
module RxDect(
        input               iRstN       ,
        input               iPclk       ,
        input               iVs         ,
        input  [47:0]       iData       ,
        
        output reg [7:0]    oDataErr    
		);
       
reg [47:0] RefData;        
        
always@(posedge iPclk or negedge iRstN)  
    if((!iRstN) | (RefData[7:0] == 8'hff))
        RefData <= 'd0;
    else if(iVs)
        RefData <= RefData + 48'h010101_010101;
    else 
        RefData <= 'd0;

always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[0] <= 'd0;
    else if(iVs && (iData[7:0] != RefData[7:0]))
        oDataErr[0] <= 'd1;    

always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[1] <= 'd0;
    else if(iVs && (iData[15:8] != RefData[15:8]))
        oDataErr[1] <= 'd1;    

always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[2] <= 'd0;
    else if(iVs && (iData[23:16] != RefData[23:16]))
        oDataErr[2] <= 'd1;    

always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[4] <= 'd0;
    else if(iVs && (iData[31:24] != RefData[31:24]))
        oDataErr[4] <= 'd1;    
        
always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[5] <= 'd0;
    else if(iVs && (iData[39:32] != RefData[39:32]))
        oDataErr[5] <= 'd1;    
        
always@(posedge iPclk or negedge iRstN)  
    if(!iRstN)
        oDataErr[6] <= 'd0;
    else if(iVs && (iData[47:40] != RefData[47:40]))
        oDataErr[6] <= 'd1;    

always@(posedge iPclk) begin
    oDataErr[3] <= 'd0;
    oDataErr[7] <= 'd0;
end


endmodule